'use strict';
var inherit = require('./utils').inherit;
var Page = require('./page');
var Track = require('./track');
/**
* Initialize new `Screen` facade with `dictionary`.
*
* @param {Object} dictionary
* @param {string} category
* @param {string} name
* @param {Object} traits
* @param {Object} options
* @param {Object} opts
* @property {boolean|undefined} clone
*/
function Screen(dictionary, opts) {
Page.call(this, dictionary, opts);
}
/**
* Inherit from `Page`
*/
inherit(Screen, Page);
/**
* Get the facade's action.
*
* @api public
* @return {string}
*/
Screen.prototype.action = function() {
return 'screen';
};
Screen.prototype.type = Screen.prototype.action;
/**
* Get event with `name`.
*
* @api public
* @param {string} name
* @return {string}
*/
Screen.prototype.event = function(name) {
return name ? 'Viewed ' + name + ' Screen' : 'Loaded a Screen';
};
/**
* Convert this Screen.
*
* @api public
* @param {string} name
* @return {Track}
*/
Screen.prototype.track = function(name) {
var json = this.json();
json.event = this.event(name);
json.timestamp = this.timestamp();
json.properties = this.properties();
return new Track(json, this.opts);
};
/**
* Exports.
*/
module.exports = Screen;
|